Ext.define('component.customer.cusSignPanel', {
	extend : 'Ext.form.Panel',
	initComponent:function(){
	
	var gridStores = Ext.create('Ext.data.Store', {
        fields: ["id","didTime","combinedName", "userName","taskUserName","auditStatus","smTartTime","ckEndTime"
                 ,"businessStatus","customerId","checkDate","m_businessStatus"],
        pageSize: 10,  //页容量5条数据
        //是否在服务端排序 （true的话，在客户端就不能排序）
        remoteSort: false,
        proxy: {
            type: 'ajax',
            url: jypath+'/customer/signed/getPageDtoByCustomerId',
            actionMethods: { read: 'POST' },
            reader: {   //这里的reader为数据存储组织的地方，下面的配置是为json格式的数据，例如：[{"total":50,"rows":[{"a":"3","b":"4"}]}]
                type: 'json', //返回数据类型为json格式
                root: 'rows',  //数据
                totalProperty: 'total' //数据总条数
            }
        },
        autoLoad: true  //即时加载数据
    });
	
	gridStores.on("beforeload",function(){
        Ext.apply(gridStores.proxy.extraParams,{customerId:customerId});
    });
	
	var grids = Ext.create('Ext.grid.Panel', {
		id:"gridStoreList3",
		minHeight:600,
        store: gridStores,
        columnLines: true,
        columns: [{
            text: '签约日期',
            dataIndex: 'didTime',
            renderer:function(value){
            	return Ext.Date.format(new Date(value),'Y-m-d')
            }
        },{
            text     : '签约房源',
            width : 350,
            dataIndex: 'combinedName'
        },{
            text     : '经纪人',
            dataIndex: 'userName'
        },{
            text     : '审核人',
            dataIndex: 'taskUserName'
        },{
            text     : '审核结果',
            dataIndex: 'auditStatus',
            renderer : function(val) {
                if (val == 0) {
                    return '待提交';
                } else if (val == 1) {
                    return '审核中';
                }else if (val == 2) {
                    return '驳回';
                }else if (val == 3) {
                    return '成功';
                }
                return val;
            }
        },{
            text: '提交时间',
            dataIndex: 'smTartTime',
            renderer:function(value){
            	if(value)
            	return Ext.Date.format(new Date(value),'Y-m-d G:i:s')
            }
        },{
            text: '审核时间',
            dataIndex: 'checkDate',
            renderer:function(value){
            	if(value)
            	return Ext.Date.format(new Date(value),'Y-m-d G:i:s')
            }
        },{
            text     : '业务状态',
            dataIndex: 'm_businessStatus'
            /*dataIndex: 'businessStatus',
            renderer : function(val) {
                if (val == 1) {
                    return '签约';
                } else if (val == 2) {
                    return '已退房';
                }else if (val == 3) {
                    return '已换房';
                }else if (val == 4) {
                    return '已更名';
                }
                return val;
            }*/
        },{  
        	text : "操作",  
            dataIndex: 'actioncolumn',
            hidden:queryButton,
            renderer: function(value,cellmeta,record,rowIndex,columnIndex,store) {
                var rec = grids.getStore().getAt(rowIndex);
                //查看
                var tabKey = "sig_"+rec.get('id');
                var html = "<a href='javascript:parent.openMenu(\"0\",\""+tabKey+"\",\"\",\"签约详情\",\"/customer/signed/toView?id="+rec.get('id')+"&returnUrl=,marketing,pin,index\")' style='cursor:pointer'>查看</a>";

                if(rec.get('auditStatus')==3) {
                    html += "&emsp;<a href='javascript:parent.openMenu(\"0\",\"print_" + tabKey + "\",\"\",\"签约单打印\",\"/customer/signed/toPrint?id=" + rec.get('id') + "&returnUrl=,marketing,pin,index\")' style='cursor:pointer'>打印</a>";
                }
                return html;
        	}
        }],
        title: '签约列表',
        dockedItems: [{  
            xtype: 'pagingtoolbar',  
            store: gridStores,   // GridPanel中使用的数据  
            dock: 'bottom',  
            displayInfo: true,  
            emptyMsg:"没有数据",  
            displayMsg:"显示从{0}条数据到{1}条数据，共{2}条数据"
        }
        ]
    });
	
		
		var defaultConfigg = {
				defaults: {  
		            split: true,    //有分割线  
		            collapsible: true,  //可以折叠
		        },
				items:[grids]
		};
		Ext.apply(this,defaultConfigg);
		this.callParent(arguments);
		
	}
});
